﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;

namespace Enter.Common.Helper
{
	/// <summary>
	/// 日志处理
	/// </summary>
	public class LogHelper
	{
		private static readonly ILog ILog = null;
		static LogHelper()
		{
			//try
			//{
			//    log4net.Config.XmlConfigurator.Configure(new FileInfo(GetFile()));
			//}
			//catch { }
			ILog = LogManager.GetLogger(typeof(LogHelper));
		}

		/// <summary>
		/// 写日志，默认级别是 LogLevel.Error
		/// </summary>
		/// <param name="message">写日志的内容</param>
		public static void LogInfo(string message)
		{
			ILog.Info(message);
		}


		/// <summary>
		/// 写日志，默认级别是 LogLevel.Error
		/// </summary>
		/// <param name="message">写日志的内容</param>
		public static void Log(string message)
		{
			LogError(message);
		}

		/// <summary>
		/// 写日志，默认级别是 LogLevel.Error
		/// </summary>
		/// <param name="message">写日志的内容</param>
		public static void LogError(string message)
		{
			ILog.Error(message);
		}


		/// <summary>
		/// 写日志，默认日志级别是 LogLevel.Error。会根据异常的类型来判断是否发送通知邮件
		/// </summary>
		/// <param name="exception">异常信息</param>
		public static void Log(Exception exception)
		{
			LogError(exception);
		}

		/// <summary>
		/// 写日志，默认级别是 LogLevel.Error
		/// </summary>
		/// <param name="message">写日志的内容</param>
		public static void LogInfo(Exception exception)
		{
			ILog.Info(exception);
		}


		/// <summary>
		/// 写日志，默认级别是 LogLevel.Error
		/// </summary>
		/// <param name="message">写日志的内容</param>
		public static void LogError(Exception exception)
		{
			ILog.Error(exception);
		}

	}
}
